// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗   ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗  ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║   ██║   ██║   ██║██║     █████╗
// ██║╚██╗██║██║   ██║   ██║   ██║██║     ██╔══╝
// ██║ ╚████║╚██████╔╝   ██║   ██║╚██████╗███████╗
// ╚═╝  ╚═══╝ ╚═════╝    ╚═╝   ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text.Json;
using System.Text.Json.Serialization;

#nullable restore
namespace Elastic.Clients.Elasticsearch
{
	public sealed partial class Destination
	{
		[JsonInclude]
		[JsonPropertyName("index")]
		public Elastic.Clients.Elasticsearch.IndexName Index { get; set; }

		[JsonInclude]
		[JsonPropertyName("op_type")]
		public Elastic.Clients.Elasticsearch.OpType? OpType { get; set; }

		[JsonInclude]
		[JsonPropertyName("pipeline")]
		public string? Pipeline { get; set; }

		[JsonInclude]
		[JsonPropertyName("routing")]
		public Elastic.Clients.Elasticsearch.Routing? Routing { get; set; }

		[JsonInclude]
		[JsonPropertyName("version_type")]
		public Elastic.Clients.Elasticsearch.VersionType? VersionType { get; set; }
	}

	public sealed partial class DestinationDescriptor : SerializableDescriptorBase<DestinationDescriptor>
	{
		internal DestinationDescriptor(Action<DestinationDescriptor> configure) => configure.Invoke(this);
		public DestinationDescriptor() : base()
		{
		}

		private Elastic.Clients.Elasticsearch.IndexName IndexValue { get; set; }

		private Elastic.Clients.Elasticsearch.OpType? OpTypeValue { get; set; }

		private string? PipelineValue { get; set; }

		private Elastic.Clients.Elasticsearch.Routing? RoutingValue { get; set; }

		private Elastic.Clients.Elasticsearch.VersionType? VersionTypeValue { get; set; }

		public DestinationDescriptor Index(Elastic.Clients.Elasticsearch.IndexName index)
		{
			IndexValue = index;
			return Self;
		}

		public DestinationDescriptor OpType(Elastic.Clients.Elasticsearch.OpType? opType)
		{
			OpTypeValue = opType;
			return Self;
		}

		public DestinationDescriptor Pipeline(string? pipeline)
		{
			PipelineValue = pipeline;
			return Self;
		}

		public DestinationDescriptor Routing(Elastic.Clients.Elasticsearch.Routing? routing)
		{
			RoutingValue = routing;
			return Self;
		}

		public DestinationDescriptor VersionType(Elastic.Clients.Elasticsearch.VersionType? versionType)
		{
			VersionTypeValue = versionType;
			return Self;
		}

		protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
		{
			writer.WriteStartObject();
			writer.WritePropertyName("index");
			JsonSerializer.Serialize(writer, IndexValue, options);
			if (OpTypeValue is not null)
			{
				writer.WritePropertyName("op_type");
				JsonSerializer.Serialize(writer, OpTypeValue, options);
			}

			if (!string.IsNullOrEmpty(PipelineValue))
			{
				writer.WritePropertyName("pipeline");
				writer.WriteStringValue(PipelineValue);
			}

			if (RoutingValue is not null)
			{
				writer.WritePropertyName("routing");
				JsonSerializer.Serialize(writer, RoutingValue, options);
			}

			if (VersionTypeValue is not null)
			{
				writer.WritePropertyName("version_type");
				JsonSerializer.Serialize(writer, VersionTypeValue, options);
			}

			writer.WriteEndObject();
		}
	}
}